//
//  RecSectionView.swift
//

import UIKit

class RecSectionView: UICollectionViewSectionColorReusableView {

    var didSelectedMore: () -> Void = {}
    
    lazy var titleLabel: UILabel = {
        let view = UILabel()
        view.textColor = UIColor.sysBlack
        view.font = 20.boldFont
        return view
    }()
    
    lazy var rightLabel: UILabel = {
        let view = UILabel()
        view.textColor = UIColor.theme
        view.font = 13.font
        view.textAlignment = .right
        view.isUserInteractionEnabled = true
        let tap = UITapGestureRecognizer(target: self, action: #selector(moreClick))
        view.addGestureRecognizer(tap)
        return view
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        addSubviews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func addSubviews() {
        backgroundColor = UIColor.sysWhite
        addSubview(titleLabel)
        addSubview(rightLabel)
        
        titleLabel.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview().offset(-5.fit)
            make.left.equalToSuperview().offset(space)
        }
        
        rightLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(titleLabel.snp.centerY)
            make.right.equalToSuperview().offset(-space)
            make.width.equalTo(100.fit)
        }
    }

    @objc private func moreClick() {
        didSelectedMore()
    }
}
